import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { type IActicle } from "../../types";

export interface IArticlesState {
    list: IActicle[]
}

const slice = createSlice({
    name: 'articles',
    initialState: {
        list: []
    } as IArticlesState,
    reducers: {
        addArticle: (state, actions: PayloadAction<IActicle>) => {
            state.list.push(actions.payload)
        }
    }
})

export const { addArticle } = slice.actions

export default slice.reducer
